<template>
  <div>
    <el-dialog title="新增学员" :visible.sync="thistype" @close="fun(tname)">
      <el-form label-width="150px" :model="form" ref="form">
        <el-form-item label="姓名">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="性别" >
          <el-input v-model="form.sex"></el-input>
        </el-form-item>
        <el-form-item label="身份证号" >
          <el-input v-model="form.code"></el-input>
        </el-form-item>
        <el-form-item label="手机号" >
          <el-input v-model="form.phone"></el-input>
        </el-form-item>
        <el-form-item label="前端阶段" >
          <el-input v-model="form.stage"></el-input>
        </el-form-item>
        <el-form-item label="家庭地址" >
          <el-input v-model="form.address"></el-input>
        </el-form-item>
        <el-form-item label="出生日期" >
          <el-input v-model="form.born"></el-input>
        </el-form-item>
        <el-form-item label="学历" >
          <el-input v-model="form.edu"></el-input>
        </el-form-item>
        <el-form-item label="专业">
          <el-input v-model="form.major"></el-input>
        </el-form-item>
        <el-form-item label="微信号" >
          <el-input v-model="form.wx"></el-input>
        </el-form-item>
        <el-form-item label="QQ号" >
          <el-input v-model="form.qq"></el-input>
        </el-form-item>
        <el-form-item label="目前状态">
          <el-input v-model="form.cur"></el-input>
        </el-form-item>
        <el-form-item label="目标就业城市" >
          <el-input v-model="form.city"></el-input>
        </el-form-item>
        <el-form-item label="紧急联系人" >
          <el-input v-model="form.emer"></el-input>
        </el-form-item>
        <el-form-item label="紧急联系人电话" >
          <el-input v-model="form.emerphone"></el-input>
        </el-form-item>
        <el-form-item label="顾问老师" >
          <el-input v-model="form.teacher"></el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="thistype = false">取 消</el-button>
        <el-button type="primary" @click="upuser">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ['type', 'fun', 'tname'],
  data () {
    return {
      thistype: this.type, // 模态框状态，
      form: {
        name: '', // 姓名
        sex: '', // 性别
        code: '', // 身份证号
        phone: '', // 手机号
        stage: '', // 前端阶段
        address: '', // 家庭地址
        born: '', // 出生日期
        edu: '', // 学历
        major: '', // 专业
        wx: '', // 微信
        qq: '', // qq
        cur: '', // 目前状态
        city: '', // 目标就业城市
        emer: '', // 紧急联系人
        emerphone: '', // 紧急联系人电话
        teacher: ''// 顾问老师
      }
    }
  },
  methods: {
    // 判断用户信息是否填写完整
    upuser () {
      this.thistype = false
      var type = true
      for (var i in this.form) {
        if (this.form[i] === '') {
          type = false
        }
      }
      if (type) {
        // 请求接口并传递数据
        // for (var i in this.form) {
        // this.form[i] = ''
        // console.log(this.form[i])
        // }
      } else {
        this.thistype = true
        /* for (var i in this.form) {
          this.form[i] = ''
          console.log(this.form[i])
        } */
        this.$message.error('请补全信息')
      }
    }
  },
  watch: {
    // 监听模态框的状态
    type () {
      this.thistype = this.type
    }
  }
}
</script>

<style>
</style>
